package edu.sjb;

import java.awt.Graphics;

import javax.swing.ImageIcon;
import javax.swing.JLabel;

@SuppressWarnings("serial")
public class Drawable extends JLabel implements Cloneable {
	protected boolean hidden;

	public Drawable(String imgPath, boolean h) {
		super();
		if (imgPath != null) {
			ImageIcon img = new ImageIcon(imgPath);
			setIcon(img);
			setOpaque(false);

		}
		hidden = h;
		if (h) {
			setVisible(false);
		}
	}

	public void changeImage(String imgPath) {

		ImageIcon img = new ImageIcon(imgPath);
		setIcon(img);
	}

	public void draw(Graphics g, int posX, int posY) {
		setLocation(posX, posY);
		super.paintComponents(g);
	}

	public void setHidden(boolean h) {
		if (h) {
			setVisible(false);
		}
		else {
			setVisible(true);
		}
		hidden = h;
	}

	public boolean isHidden() {
		return hidden;
	}

	protected Object clonate() {

		try {
			return this.clone();
		}
		catch (CloneNotSupportedException e) {
		}
		return null;
	}
}
